<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Vale: The Interesting Parts Comments</title><style>
    .comment {
      overflow: hidden;
      padding: 18px 0 7px 0;
      clear: both;
    }

    .comment + .comment {
      border-top: 1px solid #e8e8e8;
    }

    .comment > .json {
      display: none;
    }

    .comment-box {
      background-color: #fffbe1;
      overflow: hidden;
      padding: 6px 12px;
      margin-bottom: 8px;
    }

    .reply-box {
      background-color: #eff2f9;
      padding: 6px 12px 6px 6px;
      overflow: hidden;
      margin-bottom: 8px;
    }

    .user-name {
      font-weight: bold;
      padding-right: 10px;
    }

    .comment > .author-picture {
      float: left;
      padding: 0 20px;
    }

    .reply-box > .author-picture {
      float: left;
      padding: 0 6px;
    }

    .comment-deleted {
      color: red;
      padding-right: 10px;
    }

    .author-picture + div, .user-name, .user-name + .comment-deleted, .user-name + .comment-action {
      float: left;
    }

    .created-date {
      color: #999;
    }

    .comment-box .comment-content {
      clear: both;
    }

    .comment-box > .created-date {
      float: right;
    }

    .reply-box .created-date {
      clear: both;
    }

    .comment-context-intro {
      color: #999;
      clear: both;
    }

    .comment-context-value {
      border-left: 1px solid #ccc;
      font-style: italic;
      padding: 3px 10px 3px 10px;
    }

    .comment-action {
      font-style: italic;
    }

    .comment-status {
      font-style: italic;
      color: green;
      float: left;
      font-weight: bold;
      padding-right: 10px;
    }
  </style></head><body><section class="header"><h1>Vale: The Interesting Parts - Drive File Comments</h1></section><section><div id="AAAAYAZ721U" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Gg55PZ5YfCubxdabcpbDqPQbdsEMB3nFwKy1NWmKQ=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">thomas sartoni</div><div class="comment-status"></div><div class="created-date">Apr 13, 2022, 8:47 AM</div><div class="comment-content"><div style="font-size:13px;color:#333"><span style="font-weight:bold">Replace:</span> <span style="white-space:pre-line;color:#777;font-style:italic">“during”</span> with <span style="white-space:pre-line;color:#777;font-style:italic">“whi”</span></div></div></div><div class="reply-list"><div id="AAAAYAZ721Y" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Gg55PZ5YfCubxdabcpbDqPQbdsEMB3nFwKy1NWmKQ=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">thomas sartoni</div><div class="comment-action">Rejected suggestion</div><div class="comment-content"></div><div class="created-date">Apr 13, 2022, 8:47 AM</div></div></div></div></div></div><div id="AAAAW4Edcz0" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJxsxNVwa8vG3e09ZwTEdMD28MGMcmejcfNFADDr=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Literally Void</div><div class="comment-status"></div><div class="created-date">Apr 5, 2022, 5:31 PM</div><div class="comment-content"><div style="font-size:13px;color:#333"><span style="font-weight:bold">Add space</span></div></div></div><div class="reply-list"></div></div></div><div id="AAAADkdiu08" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ggyx67iYZGEtlXvF5znYTVniwPnoOAmKkyPxQgCvQ=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Wouter van Oortmerssen</div><div class="comment-status"></div><div class="created-date">Oct 7, 2019, 9:20 PM(edited: Dec 1, 2019, 8:04 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">Constraint References</div></div><div class="comment-content">how are these implemented? with an intrusive list of refs much like shared_ptr? meaning they are expensive?</div></div><div class="reply-list"><div id="AAAAJDv6vt8" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">Constraint refs are a nonatomic integer at the top of every struct. Weak refs will be managed by a thread-local hash map of pointer to O(1) set of back-pointers, on LLVM. On JVM, it&#39;ll be slightly different (every object will have a pointer to a &quot;box&quot; which just points back to it).</div><div class="created-date">Dec 1, 2019, 8:04 PM</div></div></div></div></div></div><div id="AAAADkdiu04" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ggyx67iYZGEtlXvF5znYTVniwPnoOAmKkyPxQgCvQ=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Wouter van Oortmerssen</div><div class="comment-status"></div><div class="created-date">Oct 7, 2019, 9:16 PM(edited: Dec 1, 2019, 8:01 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">For this reason</div></div><div class="comment-content">based on one use case.. can you think of use cases where shared is better? for example where an object has N users, but there is no obvious preferred owner that should finish touching the object last?</div></div><div class="reply-list"><div id="AAAAJDv6vt0" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">Yep, there are a few cases that I&#39;ve seen where shared ownership was a better choice, but it&#39;s very rare. One can implement shared references using single ownership, so I&#39;ll leave that to the STL.</div><div class="created-date">Dec 1, 2019, 8:01 PM</div></div></div></div></div></div><div id="AAAADkdiu0g" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ggyx67iYZGEtlXvF5znYTVniwPnoOAmKkyPxQgCvQ=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Wouter van Oortmerssen</div><div class="comment-status"></div><div class="created-date">Oct 7, 2019, 9:13 PM(edited: Dec 1, 2019, 7:59 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">This is actually a good outcome compared to what we&amp;#39;ve seen so far.</div></div><div class="comment-content">still bad the socket keeps processing a dead listener, though.. and eventually the sockets listener list could be arbitrarily long</div></div><div class="reply-list"><div id="AAAAJDv6vts" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">Very true, this would probably be a good case for constraint references then, so we force ourselves to clean up the entry in the observers list. The alternative would be clearing out any nulls (perhaps on iteration) from the list.</div><div class="created-date">Dec 1, 2019, 7:59 PM</div></div></div></div></div></div><div id="AAAADkdiu0c" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ggyx67iYZGEtlXvF5znYTVniwPnoOAmKkyPxQgCvQ=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Wouter van Oortmerssen</div><div class="comment-status"></div><div class="created-date">Oct 7, 2019, 9:12 PM(edited: Dec 1, 2019, 7:58 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">unlet</div></div><div class="comment-content">:)</div></div><div class="reply-list"><div id="AAAAJDv6vto" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">Yep, it&#39;s the opposite of let, it removes the variable... though now that I&#39;m getting rid of let, I&#39;m not sure what I&#39;ll name this keyword.</div><div class="created-date">Dec 1, 2019, 7:58 PM</div></div></div></div></div></div><div id="AAAADVzyqmQ" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Kim S</div><div class="comment-status"></div><div class="created-date">Aug 15, 2019, 8:52 AM(edited: Aug 15, 2019, 3:20 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">first time</div></div><div class="comment-content">Okay obligatory &quot;mobile exists&quot; moment. So with Android (and most probably iOS too), your program can be killed at any time when it&#39;s in the background and views can be recycled without killing the program (I think). <br><br>An example of the most common crashes I&#39;ve seen/caused:<br>You register your listener, your app is paused, an event comes in, oh look the view doesn&#39;t actually exist anymore because Android needed the memory for other things, BAM null pointer exception trying to process the event and update a view that was deconstructed. <br>The trick here is that your Activity was never killed so your listener is technically valid, but the listener contains a reference to something that was killed. I&#39;m curious if this section is solving this problem too? <br><br>Also in the case of mobile, your app might not be cleaned up. But maybe it will be. Luckily there&#39;s a developer option that forces things to be cleaned up: <a href="https://www.google.com/url?q=https://stackoverflow.com/a/22402360&amp;sa=D&amp;source=docs&amp;ust=1653194666350090&amp;usg=AOvVaw0mVURbagUPioSvKaS1jFHY" data-rawhref="https://stackoverflow.com/a/22402360" target="_blank">https://stackoverflow.com/a/22402360</a> but I&#39;m not sure how reliable that is at simulating the weird behavior the OS can do.<br><br>Oh and to solve this issue you either have to nullcheck view in the listener before modifying it, or when the app is paused you have to unregister your listener (not destroy it, just unregister until the app is resumed) <br><br>Aaaand lovely Android side-note: Android gives certain guarantees that onPause will always be called, but onDestroy is not guaranteed to be called (<a href="https://www.google.com/url?q=https://stackoverflow.com/a/18361887&amp;sa=D&amp;source=docs&amp;ust=1653194666350284&amp;usg=AOvVaw2iqf7C_vl13QWtXbaAnnrh" data-rawhref="https://stackoverflow.com/a/18361887" target="_blank">https://stackoverflow.com/a/18361887</a>). Given that your app is completely and utterly killed I&#39;m not sure it matters if it <b>also</b> crashes because of constraint references, but fyi this behavior exists</div></div><div class="reply-list"><div id="AAAADVzyqmU" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Kim S</div><div class="comment-content">So uh, tl;dr how do constraint references play in a system where you&#39;re fighting the OS for ultimate power--- er--- a bit of CPU time?</div><div class="created-date">Aug 15, 2019, 8:55 AM</div></div></div><div id="AAAADVzyq8k" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">Wow, that&#39;s some good intel, thanks! I had no idea zombie objects were such a big problem in Android.<br><br>If Android was completely written in Vale, then constraint references should indeed help with finding these bugs sooner; once Android tried to destroy the activity, Vale would detect active constraint references and halt the program (and if not, it would null out any incoming weak refs and continue on). I imagine it would become a common practice to only have weak pointers to activities.<br><br>But, that&#39;s all moot, since one won&#39;t use Vale to interface with an OS, and Android will never be rewritten in Vale. Vale will be for the shared code layer.<br><br>Some details on Vale&#39;s interop with outside languages:<br>- Java/Kotlin themselves won&#39;t be able to have constraint references to things inside Vale; outside languages will basically only be able to have weak references (a generated wrapper around a &quot;Vale object ID&quot;). We won&#39;t have constraint references from the outside pointing in.<br>- Vale can&#39;t have any constraint references to things outside Vale, so it won&#39;t have any constraint references to nondeterministically destroyable data. It <i>does</i> have &quot;native&quot; references as a last resort though, but on JVM, they&#39;re regular references that would keep the object alive, they don&#39;t halt the app.<br><br>TL;DR: Vale should avoid this problem completely, and leave it to the outside java/kotlin code to deal with, as god intended.<br><br>Also, just curious, why would Android not call a function when an activity is destroyed like that? Or at least call a function on the program to let it know that &quot;hey, you&#39;re being unbackgrounded, but just so you know, a minute ago I killed an activity...&quot;?</div><div class="created-date">Aug 15, 2019, 3:20 PM</div></div></div></div></div></div><div id="AAAADVzyqmA" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Kim S</div><div class="comment-status"></div><div class="created-date">Aug 15, 2019, 8:27 AM</div><div class="comment-content"><div style="font-size:13px;color:#333"><span style="font-weight:bold">Add:</span> <span style="white-space:pre-line;color:#777;font-style:italic">“)”</span></div></div></div><div class="reply-list"><div id="AAAADVzyqmE" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Kim S</div><div class="comment-action">Rejected suggestion</div><div class="comment-content"></div><div class="created-date">Aug 15, 2019, 8:27 AM</div></div></div></div></div></div><div id="AAAADVzyql8" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Kim S</div><div class="comment-status"></div><div class="created-date">Aug 15, 2019, 8:27 AM</div><div class="comment-content"><div style="font-size:13px;color:#333"><span style="font-weight:bold">Replace:</span> <span style="white-space:pre-line;color:#777;font-style:italic">“are”</span> with <span style="white-space:pre-line;color:#777;font-style:italic">“(”</span></div></div></div><div class="reply-list"><div id="AAAADVzyqmI" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Kim S</div><div class="comment-action">Rejected suggestion</div><div class="comment-content"></div><div class="created-date">Aug 15, 2019, 8:27 AM</div></div></div></div></div></div><div id="AAAADVzyql4" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Kim S</div><div class="comment-status"></div><div class="created-date">Aug 15, 2019, 8:24 AM(edited: Aug 15, 2019, 2:58 PM)</div><div class="comment-content"><div style="font-size:13px;color:#333"><span style="font-weight:bold">Add:</span> <span style="white-space:pre-line;color:#777;font-style:italic">“if”</span></div></div></div><div class="reply-list"><div id="AAAADVzyq5Y" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-action">Accepted suggestion</div><div class="comment-content"></div><div class="created-date">Aug 15, 2019, 2:58 PM</div></div></div></div></div></div><div id="AAAADVzyql0" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Kim S</div><div class="comment-status"></div><div class="created-date">Aug 15, 2019, 8:23 AM(edited: Aug 15, 2019, 2:58 PM)</div><div class="comment-content"><div style="font-size:13px;color:#333"><span style="font-weight:bold">Add:</span> <span style="white-space:pre-line;color:#777;font-style:italic">“l”</span></div></div></div><div class="reply-list"><div id="AAAADVzyq5Q" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-action">Accepted suggestion</div><div class="comment-content"></div><div class="created-date">Aug 15, 2019, 2:58 PM</div></div></div></div></div></div><div id="AAAADVzyqlw" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Kim S</div><div class="comment-status"></div><div class="created-date">Aug 15, 2019, 8:20 AM(edited: Aug 15, 2019, 2:57 PM)</div><div class="comment-content"><div style="font-size:13px;color:#333"><span style="font-weight:bold">Replace:</span> <span style="white-space:pre-line;color:#777;font-style:italic">“d”</span> with <span style="white-space:pre-line;color:#777;font-style:italic">“ve”</span></div></div></div><div class="reply-list"><div id="AAAADVzyq5E" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-action">Accepted suggestion</div><div class="comment-content"></div><div class="created-date">Aug 15, 2019, 2:57 PM</div></div></div></div></div></div><div id="AAAADVzyqlo" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Kim S</div><div class="comment-status"></div><div class="created-date">Aug 15, 2019, 8:20 AM</div><div class="comment-content"><div style="font-size:13px;color:#333"><span style="font-weight:bold">Replace:</span> <span style="white-space:pre-line;color:#777;font-style:italic">“had”</span> with <span style="white-space:pre-line;color:#777;font-style:italic">“had”</span></div></div></div><div class="reply-list"><div id="AAAADVzyqls" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Kim S</div><div class="comment-action">Rejected suggestion</div><div class="comment-content"></div><div class="created-date">Aug 15, 2019, 8:20 AM</div></div></div></div></div></div><div id="AAAADVzyqlk" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghn5bvDPC20zm_avmlnK16x5R5jIT-pEG78QReWoa8=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Kim S</div><div class="comment-status"></div><div class="created-date">Aug 15, 2019, 8:19 AM(edited: Aug 15, 2019, 2:57 PM)</div><div class="comment-content"><div style="font-size:13px;color:#333"><span style="font-weight:bold">Replace:</span> <span style="white-space:pre-line;color:#777;font-style:italic">“ed”</span> with <span style="white-space:pre-line;color:#777;font-style:italic">“s”</span></div></div></div><div class="reply-list"><div id="AAAADVzyq5I" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-action">Accepted suggestion</div><div class="comment-content"></div><div class="created-date">Aug 15, 2019, 2:57 PM</div></div></div></div></div></div></section></body></html>